<?php

namespace Common\Model;

use Think\Model;

class BbsPraiseModel extends Model
{
    protected $_auto = array(
        array('addtime', 'time', 1, 'function')
    );

    /**
     * 添加主题点赞
     * @param int $uid
     * @param int $bid
     */
    public function praise_add($uid, $bid)
    {
        if (!$this->create(compact('uid', 'bid'))) {
            $res['status'] = false;
            $res['msg'] = $this->getError();
            return $res;
        } else {
            $newid = $this->add();
            if (!$newid) {
                $res['status'] = false;
                $res['msg'] = '点赞失败';
                return $res;
            } else {
                $res['status'] = true;
                $res['msg'] = '点赞成功';
                return $res;
            }
        }
    }
}